home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 11952 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.2 KB

  1. Path: symiserver2.symantec.com!usenet
  2. From: Walter Bright <wbright@symantec.com>
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Inline Assembler and OOP
  5. Date: Sat, 16 Mar 1996 15:11:12 -0800
  6. Organization: Symantec Development Tools Business Unit
  7. Message-ID: <314B4A90.64BE@symantec.com>
  8. References: <4iaqcn$mfu@masala.cc.uh.edu>
  9. NNTP-Posting-Host: 155.64.77.131
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13. X-Mailer: Mozilla 2.0 (WinNT; I)
  14.  
  15. Sensarn wrote:
  16. < struct double_buffer {
  17. <     unsigned char *buffer; /* Actual data */
  18. <     unsigned int buffer_size; /* Actual size of buffer */
  19. <     double_buffer(int num_lines=200); /* Constructor */
  20. < };
  21. < double_buffer::double_buffer(int num_lines) {
  22. <     asm {
  23. <         les di,buffer /* Expression syntax error here */
  24. <         mov cx,buffer_size/2 /* Here too */
  25. <     }
  26. < }
  27. < Is there some reason why I cannot access buffer and buffer_size in the
  28. < asm statement (even though the asm statement is inside a member
  29. < function).
  30.  
  31. The trouble is that 'buffer' can only be accessed through the 'this' pointer. 
  32. Your asm code needs to be rewritten as:
  33.     les di,this
  34.     mov cx,es:buffer_size[di]
  35.     shr cx,1
  36.     les di,es:buffer[di]
  37.